import { CSSProperties } from 'react'
import Icon from '@ant-design/icons'

import AirfreightIcon from '@/assets/icons/airfreight.svg?react'
import LandTransportation from '@/assets/icons/landTransportation.svg?react'
import OceanFreightIcon from '@/assets/icons/oceanFreight.svg?react'
import RailwayIcon from '@/assets/icons/railway.svg?react'

const Icons = {
  1: OceanFreightIcon,
  2: AirfreightIcon,
  3: LandTransportation,
  4: RailwayIcon,
}

/** 物流运输类型icon */
export const LogisticsIcon = ({
  style,
  className,
  type,
}: {
  style?: CSSProperties
  className?: string
  /** 运输类型 */
  type: 1 | 2 | 3 | 4 | null | undefined
}) => {
  if (!type) return null

  const IconComp = Icons[type]

  if (!IconComp) return null

  return <Icon style={style} className={className} component={IconComp} />
}
